import {BoutiquesongList,SonglistClassification,SelectednetizensList,PopularsongList,
  SonglistlabelList,Songlistdetailsdynamic,AllthesongsinthesongList,SonglistDetails,Songlistcollector,
  Songlistreview
} from '@/api/api.js'
const state ={
  //获取精品歌单
  BoutiquesongList:[],
  //获取精品歌单分类
  SonglistClassification:{},
  //网友精选歌单
  playlists:[],
  //获取热门分类
  tags:[],
  //精品歌单标签列表
  SonglistlabelList:[],
  //获取歌单详情
  playlist1:{},
  //获取歌单动态
  Details:{},
  //获取歌单所有歌曲
  songs:[],
  //歌单收藏者
  subscribers:[],
  //歌单评论
  commentsandhotComments:{}
};
const mutations ={
  //获取精品歌单
  BOUTIQUESONGLIST(state,BoutiquesongList){
    state.BoutiquesongList = BoutiquesongList
  },
  //获取精品歌单分类
  SONGLISTCLASSFICATION(state,SonglistClassification){
    state.SonglistClassification = SonglistClassification
  },
  //网友精选歌单
  SELECTEDNETIZENSLIST(state,playlists){
    state.playlists = playlists
  },
  //获取热门分类
  POPULARSONGLIST(state,tags){
    state.tags = tags
  },
  //精品歌单标签列表
  SONGLISTTLABEILIST(state,SonglistlabelList){
    state.SonglistlabelList = SonglistlabelList
  },
  //获取歌单详情
  SONGLISTDETAILSS(state,playlist1){
    state.playlist1 = playlist1
  },
  //获取歌单动态
  SONGLISTDETAILSDYNAMIC(state,Details){
    state.Details = Details
  },
  //获取歌单所用歌曲
  ALLTHESONGSINTHESONGLIST(state,songs){
    state.songs = songs
  },
  //歌单收藏者
  SONGLISTCOLLECTOR(state,subscribers){
    state.subscribers = subscribers
  },
  //歌单评论
  SONGLISTREVIEW(state,commentsandhotComments){
    state.commentsandhotComments = commentsandhotComments
  }
};
const actions ={
//获取精品歌单
async getBoutiquesongList({commit},{cat}){
let request = await BoutiquesongList(cat)
if(request.data.code==200){
  commit('BOUTIQUESONGLIST',request.data.playlists)
}
},
//获取精品歌单分类
async getSonglistClassification({commit}){
let request = await SonglistClassification()
if(request.data.code==200){
  commit('SONGLISTCLASSFICATION',request.data)
}
},
//网友精选歌单
async getSelectednetizensList({commit},{cat}){
 let request = await SelectednetizensList(cat)
 if(request.data.code==200){
  commit('SELECTEDNETIZENSLIST',request.data.playlists)
 }
},
//获取热门歌单分类
async getPopularsongList({commit}){
 let request = await PopularsongList()
 if(request.data.code==200){
  commit('POPULARSONGLIST',request.data.tags)
 }
},
//精品歌单标签列表
async getSonglistlabelList({commit}){
let request = await SonglistlabelList()
if(request.data.code==200){
  commit("SONGLISTTLABEILIST",request.data.tags)
}
},
//歌单详情动态
 async getSonglistdetailsdynamic({commit},{id}){
  let request = await Songlistdetailsdynamic(id)
  if(request.data.code==200){
    commit('SONGLISTDETAILSDYNAMIC',request.data)
  }
  },
  //获取歌单所有歌曲
 async getAllthesongsinthesongList({commit},{id}){
 let request =  await AllthesongsinthesongList(id)
 if(request.data.code==200){
  commit('ALLTHESONGSINTHESONGLIST',request.data.songs)
 }
 console.log(request);
  },
  //获取歌单详情
 async getSonglistDetails({commit},{id}){
  let request = await SonglistDetails(id)
  if(request.data.code==200){
    commit('SONGLISTDETAILSS',request.data.playlist)
  }
  },
  //歌单收藏者
 async getSonglistcollector({commit},{id,limit}){
  let request = await Songlistcollector({id,limit})
  if(request.data.code==200){
    commit('SONGLISTCOLLECTOR',request.data.subscribers)
  }
  },
  //歌单评论
 async getSonglistreview({commit},{id,limit,offset}){
  let request = await Songlistreview({id,limit,offset})
  console.log(request);
  if(request.data.code==200){
    commit('SONGLISTREVIEW',request.data)
  }
  }
};
const getter = {

};
export default {
  state,
  mutations,
  actions,
  getter
}